<?php
	
	class WikinewsController{
		
		var $HOMEPAGE_TYPE = 0;
		var $LAST_NEWS_TYPE = 1;
		var $ARCHIVES_C_TYPE = 2;
		var $ARCHIVES_RO_TYPE = 3;
		var $THEMATIC_PORTAL_TYPE = 4;
		var $ARTICLE_TYPE = 5;
		var $WIKINEWS_HOMEPAGE_URL = 'http://fr.wikinews.org/wiki/Accueil';
		var $WIKINEWS_ARCHIVES_C_URL = 'http://fr.wikinews.org/wiki/Cat%C3%A9gorie:Principale';
		var $WIKINEWS_ARCHIVES_RO_URL = 'http://fr.wikinews.org/wiki/Cat%C3%A9gorie:Reportage_original';
		
		var $typeParser;
		var $model;
		var $url;
	
		function WikinewsController($url, $model){
			$this->initParserWikinews($url);
			$this->model = $model;
			$model->init($model->WIKINEWS_PARSER, $this->url,$this->typeParser);
		}
		
		function initParserWikinews($url){
			if(strpos($url,'Accueil') !== FALSE && strlen($url) == 35){
				$this->typeParser = $this->HOMEPAGE_TYPE;
				$this->url = $url;
			}else if(strpos($url,'SAW_lastnews') !== FALSE){
				$this->typeParser = $this->LAST_NEWS_TYPE;
				$this->url = $this->WIKINEWS_HOMEPAGE_URL;
			}else if(strpos($url,'SAW_archives_C') !== FALSE){
				$this->typeParser = $this->ARCHIVES_C_TYPE;
				$this->url = $this->WIKINEWS_ARCHIVES_C_URL;
			}else if(strpos($url,'SAW_archives_RO') !== FALSE){
				$this->typeParser = $this->ARCHIVES_RO_TYPE;
				$this->url = $this->WIKINEWS_ARCHIVES_RO_URL;
			}else if(strpos($url,'SAW_thematic_portal') !== FALSE){
				$this->typeParser = $this->THEMATIC_PORTAL_TYPE;
				$this->url = $this->WIKINEWS_HOMEPAGE_URL;
			}else if(strpos($url,'SAW_article') !== FALSE){
				$this->typeParser = $this->ARTICLE_TYPE;
				$this->url = $this->WIKINEWS_HOMEPAGE_URL;
			}else{
				$this->typeParser = $this->ARTICLE_TYPE;
				$this->url = $url;
			}
		}
		
	}

?>